/*
 * @Author: your name
 * @Date: 2020-06-01 14:58:54
 * @LastEditTime: 2020-06-01 15:52:43
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \X\1km\agv\mag_navigation.h
 */ 
/*
mag_navigation.h
offer mag navigation data type define ,function extern
designed by lunanting

----------------------------
2020-04-28 14:09:33
create file
----------------------------
*/
#ifndef __MAG_NAVI_H
#define __MAG_NAVI_H

#include "../driver/driver.h"
#include "../algorithm/algorithm.h"  
#ifdef BATTERY_VERSION
#define __FILENAMES__ (strrchr(__FILE__,'/') ? strrchr(__FILE__,'/') + 1 : __FILE__)
#define MAG_LOG(format, args...) printf("[%s][%s][%d]: "format"\r\n",__FILENAMES__,__func__,__LINE__,##args)
/*
PID parameter
*/
#define PIDMAG_KP   (0.005)
#define PIDMAG_KI   (0)
#define PIDMAG_KD   (0)
#define ROBOT_BASESPEED  (0.05)         //  m/s
#define MAG_RECORD_LEN  (10)
#define FIND_BIG_SPEED  (0.05)
#define FIND_SML_SPEED  (0.025)
extern u8 g_only_proport_use;
extern PIDtypedef PIDMAG;
extern aos_mutex_t g_mutex_mag_navigation;
extern float g_robotspeed;
#endif


#define LEFT_RIGHT_RANG 10


/*************************data type define************************/



//mag navigation class
typedef struct{
    s8 dir; //move direction
    float angle;    //agv angle state
    s8 turn;    //agc turn state;0=no turn,<0=turning left,>0=turning right
    u8 init;    //object init state
}MAG_NAVI_class;


/**************************function extern*****************************/
#if  defined(LINE_VERSION) || defined(BATTERY_VERSION)
extern int xp_mag_navigation_init(void);    //mag navagation module init
extern int xp_mag_navigation_move(s8 dir);  //mag navigation move
#endif
#ifdef BATTERY_VERSION
extern int xp_mag_navigation_b_debug(char *type,char *fun,char *param);    //mag navigation debug
extern void xp_mag_move_start_or_stop(u8 flag);
extern int xp_mag_get_mag_flag(void);

#endif
extern void xp_mag_navi_test(void); //mag navvigion test
extern int xp_mag_navigation_debug(char *type,char *fun,char *param);    //mag navigation debug
#endif
//end of the file
